home *** CD-ROM | disk | FTP | other *** search
/ Amiga News 95 / Amiga News 95.iso / dpat / dpat24 / intui-dkb1.0 / intui-dkb1.0.c < prev    next >
Encoding:
C/C++ Source or Header  |  1993-01-21  |  13.3 KB  |  804 lines

  1. /*      source du programme :               */
  2. /*        © INTUI-DKB 1.0                   */
  3. /*       Sébastien Bouchex                  */
  4. /*          version 1.0                     */
  5. /*                                          */
  6. /*      - utilisation de req.library        */
  7. /*      - compatible avec DKB-Trace 2.0     */
  8. /*                                          */
  9.  
  10. #include <stdio.h>
  11. #include <intuition/intuition.h>
  12. #include <exec/libraries.h>
  13. #include <libraries/dosextens.h>
  14. #include <libraries/dos.h>
  15. #include <libraries/ReqBase.h>
  16.  
  17. /* variables chaines utilisées */
  18. char source_nom[FCHARS]=NULL;
  19. char source_dir[DSIZE]=NULL;
  20. char source[DSIZE+FCHARS]=NULL;
  21. char cible_nom[FCHARS]=NULL;
  22. char cible_dir[DSIZE]=NULL;
  23. char cible[DSIZE+FCHARS]=NULL;
  24. char hauteur[5]=NULL,largeur[5]=NULL,debut[5]=NULL,
  25.      fin[5]=NULL,lissage[5]=NULL,qualite[3]=NULL,tampon[5]=NULL;
  26. struct ReqFileRequester req_cible=NULL;
  27. struct ReqFileRequester req_source=NULL;
  28.  
  29. /* variables du programme */
  30. struct Window *f1=NULL;
  31. struct ReqBase *ReqBase=NULL;
  32. char commande[240]="run ";
  33. char nom_calcul[10]=NULL;
  34. char fichier_config[25]="s:intui-dkb1.0.config";
  35. struct IntuiMessage *im=NULL;
  36. char drapeau=0;
  37.  
  38. SHORT BorderVectors1[] = {
  39.         0,0,
  40.         76,0,
  41.         76,23,
  42.         0,23,
  43.         0,0
  44. };
  45.  
  46. struct Border Border1 = {
  47.         -2,-1,1,0,JAM1,5,BorderVectors1,NULL};
  48.  
  49. struct IntuiText IText1 = {
  50.         1,0,JAM2,
  51.         12,8,
  52.         NULL,
  53.         "SORTIE",
  54.         NULL
  55. };
  56.  
  57. struct Gadget Gadget14 = {
  58.         NULL,
  59.         308,83,
  60.         73,22,
  61.         NULL,
  62.         RELVERIFY+TOGGLESELECT,
  63.         BOOLGADGET,
  64.         (APTR)&Border1,
  65.         NULL,
  66.         &IText1,
  67.         NULL,
  68.         NULL,
  69.         14,
  70.         NULL
  71. };
  72.  
  73. SHORT BorderVectors2[] = {
  74.         0,0,
  75.         106,0,
  76.         106,25,
  77.         0,25,
  78.         0,0
  79. };
  80. struct Border Border2 = {
  81.         -2,-1,
  82.         1,0,JAM1,
  83.         5,
  84.         BorderVectors2,
  85.         NULL
  86. };
  87.  
  88. struct IntuiText IText2 = {
  89.         1,0,JAM2,
  90.         7,9,
  91.         NULL,
  92.         "C'EST PARTI",
  93.         NULL
  94. };
  95.  
  96. struct Gadget Gadget13 = {
  97.         &Gadget14,
  98.         150,149,
  99.         103,24,
  100.         NULL,
  101.         RELVERIFY,
  102.         BOOLGADGET,
  103.         (APTR)&Border2,
  104.         NULL,
  105.         &IText2,
  106.         NULL,
  107.         NULL,
  108.         13,
  109.         NULL
  110. };
  111.  
  112. SHORT BorderVectors3[] = {
  113.         0,0,
  114.         161,0,
  115.         161,20,
  116.         0,20,
  117.         0,0
  118. };
  119. struct Border Border3 = {
  120.         -2,-1,
  121.         1,0,JAM1,
  122.         5,
  123.         BorderVectors3,
  124.         NULL
  125. };
  126.  
  127. struct IntuiText IText3 = {
  128.         1,0,JAM2,
  129.         26,6,
  130.         NULL,
  131.         "FICHIER IMAGE",
  132.         NULL
  133. };
  134.  
  135. struct Gadget Gadget12 = {
  136.         &Gadget13,
  137.         207,117,
  138.         158,19,
  139.         NULL,
  140.         RELVERIFY,
  141.         BOOLGADGET,
  142.         (APTR)&Border3,
  143.         NULL,
  144.         &IText3,
  145.         NULL,
  146.         NULL,
  147.         12,
  148.         NULL
  149. };
  150.  
  151. SHORT BorderVectors4[] = {
  152.         0,0,
  153.         161,0,
  154.         161,20,
  155.         0,20,
  156.         0,0
  157. };
  158. struct Border Border4 = {
  159.         -2,-1,
  160.         1,0,JAM1,
  161.         5,
  162.         BorderVectors4,
  163.         NULL
  164. };
  165.  
  166. struct IntuiText IText4 = {
  167.         1,0,JAM2,
  168.         24,6,
  169.         NULL,
  170.         "FICHIER SOURCE",
  171.         NULL
  172. };
  173.  
  174. struct Gadget Gadget11 = {
  175.         &Gadget12,
  176.         31,117,
  177.         158,19,
  178.         NULL,
  179.         RELVERIFY,
  180.         BOOLGADGET,
  181.         (APTR)&Border4,
  182.         NULL,
  183.         &IText4,
  184.         NULL,
  185.         NULL,
  186.         11,
  187.         NULL
  188. };
  189.  
  190. SHORT BorderVectors5[] = {
  191.         0,0,
  192.         76,0,
  193.         76,23,
  194.         0,23,
  195.         0,0
  196. };
  197. struct Border Border5 = {
  198.         -2,-1,
  199.         1,0,JAM1,
  200.         5,
  201.         BorderVectors5,
  202.         NULL
  203. };
  204.  
  205. struct IntuiText IText5 = {
  206.         1,0,JAM2,
  207.         12,8,
  208.         NULL,
  209.         "NUMERO",
  210.         NULL
  211. };
  212.  
  213. struct Gadget Gadget10 = {
  214.         &Gadget11,
  215.         216,83,
  216.         73,22,
  217.         NULL,
  218.         RELVERIFY+TOGGLESELECT,
  219.         BOOLGADGET,
  220.         (APTR)&Border5,
  221.         NULL,
  222.         &IText5,
  223.         NULL,
  224.         NULL,
  225.         10,
  226.         NULL
  227. };
  228.  
  229. SHORT BorderVectors6[] = {
  230.         0,0,
  231.         76,0,
  232.         76,23,
  233.         0,23,
  234.         0,0
  235. };
  236. struct Border Border6 = {
  237.         -2,-1,
  238.         1,0,JAM1,
  239.         5,
  240.         BorderVectors6,
  241.         NULL
  242. };
  243.  
  244. struct IntuiText IText6 = {
  245.         1,0,JAM2,
  246.         9,8,
  247.         NULL,
  248.         "ATTENTE",
  249.         NULL
  250. };
  251.  
  252. struct Gadget Gadget9 = {
  253.         &Gadget10,
  254.         121,83,
  255.         73,22,
  256.         NULL,
  257.         RELVERIFY+TOGGLESELECT,
  258.         BOOLGADGET,
  259.         (APTR)&Border6,
  260.         NULL,
  261.         &IText6,
  262.         NULL,
  263.         NULL,
  264.         9,
  265.         NULL
  266. };
  267.  
  268. SHORT BorderVectors7[] = {
  269.         0,0,
  270.         76,0,
  271.         76,23,
  272.         0,23,
  273.         0,0
  274. };
  275. struct Border Border7 = {
  276.         -2,-1,
  277.         1,0,JAM1,
  278.         5,
  279.         BorderVectors7,
  280.         NULL};
  281.  
  282. struct IntuiText IText7 = {
  283.         1,0,JAM2,
  284.         9,8,
  285.         NULL,
  286.         "AFFICH.",
  287.         NULL
  288. };
  289.  
  290. struct Gadget Gadget8 = {
  291.         &Gadget9,
  292.         28,83,
  293.         73,22,
  294.         NULL,
  295.         RELVERIFY+TOGGLESELECT,
  296.         BOOLGADGET,
  297.         (APTR)&Border7,
  298.         NULL,
  299.         &IText7,
  300.         NULL,
  301.         NULL,
  302.         8,
  303.         NULL
  304. };
  305.  
  306. SHORT BorderVectors8[] = {
  307.         0,0,
  308.         76,0,
  309.         76,23,
  310.         0,23,
  311.         0,0
  312. };
  313. struct Border Border8 = {
  314.         -2,-1,
  315.         1,0,JAM1,
  316.         5,
  317.         BorderVectors8,
  318.         NULL
  319. };
  320.  
  321. struct IntuiText IText8 = {
  322.         1,0,JAM2,
  323.         13,8,
  324.         NULL,
  325.         "TAMPON",
  326.         NULL
  327. };
  328.  
  329. struct Gadget Gadget7 = {
  330.         &Gadget8,
  331.         260,52,
  332.         73,22,
  333.         NULL,
  334.         RELVERIFY,
  335.         BOOLGADGET,
  336.         (APTR)&Border8,
  337.         NULL,
  338.         &IText8,
  339.         NULL,
  340.         NULL,
  341.         7,
  342.         NULL
  343. };
  344.  
  345. SHORT BorderVectors9[] = {
  346.         0,0,
  347.         76,0,
  348.         76,23,
  349.         0,23,
  350.         0,0
  351. };
  352. struct Border Border9 = {
  353.         -2,-1,
  354.         1,0,JAM1,
  355.         5,
  356.         BorderVectors9,
  357.         NULL
  358. };
  359.  
  360. struct IntuiText IText9 = {
  361.         1,0,JAM2,
  362.         9,8,
  363.         NULL,
  364.         "QUALITE",
  365.         NULL
  366. };
  367.  
  368. struct Gadget Gadget6 = {
  369.         &Gadget7,
  370.         164,52,
  371.         73,22,
  372.         NULL,
  373.         RELVERIFY,
  374.         BOOLGADGET,
  375.         (APTR)&Border9,
  376.         NULL,
  377.         &IText9,
  378.         NULL,
  379.         NULL,
  380.         6,
  381.         NULL
  382. };
  383.  
  384. SHORT BorderVectors10[] = {
  385.         0,0,
  386.         76,0,
  387.         76,23,
  388.         0,23,
  389.         0,0
  390. };
  391. struct Border Border10 = {
  392.         -2,-1,
  393.         1,0,JAM1,
  394.         5,
  395.         BorderVectors10,
  396.         NULL
  397. };
  398.  
  399. struct IntuiText IText10 = {
  400.         1,0,JAM2,
  401.         9,8,
  402.         NULL,
  403.         "LISSAGE",
  404.         NULL
  405. };
  406.  
  407. struct Gadget Gadget5 = {
  408.         &Gadget6,
  409.         67,52,
  410.         73,22,
  411.         NULL,
  412.         RELVERIFY,
  413.         BOOLGADGET,
  414.         (APTR)&Border10,
  415.         NULL,
  416.         &IText10,
  417.         NULL,
  418.         NULL,
  419.         5,
  420.         NULL
  421. };
  422.  
  423. SHORT BorderVectors11[] = {
  424.         0,0,
  425.         76,0,
  426.         76,23,
  427.         0,23,
  428.         0,0
  429. };
  430. struct Border Border11 = {
  431.         -2,-1,
  432.         1,0,JAM1,
  433.         5,
  434.         BorderVectors11,
  435.         NULL
  436. };
  437.  
  438. struct IntuiText IText11 = {
  439.         1,0,JAM2,
  440.         20,8,
  441.         NULL,
  442.         "FIN",
  443.         NULL
  444. };
  445.  
  446. struct Gadget Gadget4 = {
  447.         &Gadget5,
  448.         303,18,
  449.         73,22,
  450.         NULL,
  451.         RELVERIFY,
  452.         BOOLGADGET,
  453.         (APTR)&Border11,
  454.         NULL,
  455.         &IText11,
  456.         NULL,
  457.         NULL,
  458.         4,
  459.         NULL
  460. };
  461.  
  462. SHORT BorderVectors12[] = {
  463.         0,0,
  464.         76,0,
  465.         76,23,
  466.         0,23,
  467.         0,0
  468. };
  469. struct Border Border12 = {
  470.         -2,-1,
  471.         1,0,JAM1,
  472.         5,
  473.         BorderVectors12,
  474.         NULL
  475. };
  476.  
  477. struct IntuiText IText12 = {
  478.         1,0,JAM2,
  479.         15,8,
  480.         NULL,
  481.         "DEBUT",
  482.         NULL
  483. };
  484.  
  485. struct Gadget Gadget3 = {
  486.         &Gadget4,
  487.         212,18,
  488.         73,22,
  489.         NULL,
  490.         RELVERIFY,
  491.         BOOLGADGET,
  492.         (APTR)&Border12,
  493.         NULL,
  494.         &IText12,
  495.         NULL,
  496.         NULL,
  497.         3,
  498.         NULL
  499. };
  500.  
  501. SHORT BorderVectors13[] = {
  502.         0,0,
  503.         76,0,
  504.         76,23,
  505.         0,23,
  506.         0,0
  507. };
  508. struct Border Border13 = {
  509.         -2,-1,
  510.         1,0,JAM1,
  511.         5,
  512.         BorderVectors13,
  513.         NULL
  514. };
  515.  
  516. struct IntuiText IText13 = {
  517.         1,0,JAM2,
  518.         9,8,
  519.         NULL,
  520.         "LARGEUR",
  521.         NULL
  522. };
  523.  
  524. struct Gadget Gadget2 = {
  525.         &Gadget3,
  526.         119,18,
  527.         73,22,
  528.         NULL,
  529.         RELVERIFY,
  530.         BOOLGADGET,
  531.         (APTR)&Border13,
  532.         NULL,
  533.         &IText13,
  534.         NULL,
  535.         NULL,
  536.         2,
  537.         NULL
  538. };
  539.  
  540. SHORT BorderVectors14[] = {
  541.         0,0,
  542.         76,0,
  543.         76,23,
  544.         0,23,
  545.         0,0
  546. };
  547. struct Border Border14 = {
  548.         -2,-1,
  549.         1,0,JAM1,
  550.         5,
  551.         BorderVectors14,
  552.         NULL
  553. };
  554.  
  555. struct IntuiText IText14 = {
  556.         1,0,JAM2,
  557.         9,8,
  558.         NULL,
  559.         "HAUTEUR",
  560.         NULL
  561. };
  562.  
  563. struct Gadget Gadget1 = {
  564.         &Gadget2,
  565.         26,18,
  566.         73,22,
  567.         NULL,
  568.         RELVERIFY,
  569.         BOOLGADGET,
  570.         (APTR)&Border14,
  571.         NULL,
  572.         &IText14,
  573.         NULL,
  574.         NULL,
  575.         1,
  576.         NULL
  577. };
  578.  
  579. struct NewWindow NewWindowStructure1 = {
  580.         166,11,
  581.         423,182,
  582.         0,3,
  583.         GADGETUP|CLOSEWINDOW,
  584.         WINDOWDRAG|WINDOWDEPTH|WINDOWCLOSE,
  585.         &Gadget1,
  586.         NULL,
  587.         "INTUI-DKB 1.0  Sébastien BOUCHEX",
  588.         NULL,
  589.         NULL,
  590.         5,5,
  591.         640,200,
  592.         WBENCHSCREEN
  593. };
  594.  
  595.  
  596. /* saisie fichier source et cible par requêtes fichiers */
  597. void fichier_source()
  598. {
  599.     req_source.PathName = source ;
  600.     req_source.Dir = source_dir;
  601.     req_source.File = source_nom;
  602.  
  603.     req_source.Flags = FRQCACHINGM ;
  604.  
  605.     req_source.dirnamescolor = 2;
  606.     req_source.devicenamescolor = 2;
  607.  
  608.     FileRequester(&req_source);
  609.  
  610.     PurgeFiles(&req_source);
  611.  
  612. }
  613.  
  614. void fichier_cible()
  615. {
  616.     req_cible.PathName = cible ;
  617.     req_cible.Dir = cible_dir;
  618.     req_cible.File = cible_nom;
  619.  
  620.     req_cible.Flags = FRQCACHINGM ;
  621.  
  622.     req_cible.dirnamescolor = 2;
  623.     req_cible.devicenamescolor = 2;
  624.  
  625.     FileRequester(&req_cible);
  626.  
  627.     PurgeFiles(&req_cible);
  628. }
  629.  
  630. void saisie_hauteur()
  631. {
  632.     GetString (hauteur,"HAUTEUR",(struct Window *)0L,10,4);
  633. }
  634.  
  635. void saisie_largeur()
  636. {
  637.     GetString (largeur,"LARGEUR",(struct Window *)0L,10,4);
  638. }
  639.  
  640. void saisie_debut()
  641. {
  642.     GetString (debut,"DEBUT",(struct Window *)0L,10,4);
  643. }
  644.  
  645. void saisie_fin()
  646. {
  647.     GetString (fin,"FIN",(struct Window *)0L,10,4);
  648. }
  649.  
  650. void saisie_qualite()
  651. {
  652.     GetString (qualite,"QUALITE",(struct Window *)0L,11,2);
  653. }
  654.  
  655. void saisie_tampon()
  656. {
  657.     GetString (tampon,"TAMPON",(struct Window *)0L,10,4);
  658.  
  659. }
  660.  
  661. void saisie_lissage()
  662. {
  663.     GetString (lissage,"LISSAGE",(struct Window *)0L,14,4);
  664. }
  665.  
  666. void feu()
  667. {
  668.     drapeau=1;
  669.     strcat (commande,nom_calcul);
  670.     strcat (commande," -i");
  671.     if (source[0]!=0)
  672.         strcat (commande,source);
  673.  
  674.     if (strcmp (hauteur,"")) {
  675.        strcat (commande," -h");
  676.        strcat (commande,hauteur);
  677.        }
  678.  
  679.     if (strcmp (largeur,"")) {
  680.         strcat (commande," -w");
  681.         strcat (commande,largeur);
  682.         }
  683.  
  684.     if (strcmp (debut,"")) {
  685.         strcat (commande," -s");
  686.         strcat (commande,debut);
  687.         }
  688.  
  689.     if (strcmp (fin,"")) {
  690.         strcat (commande," -e");
  691.         strcat (commande,fin);
  692.         }
  693.  
  694.     if (strcmp (lissage,"")) {
  695.         strcat (commande," +a");
  696.         strcat (commande,lissage);
  697.         }
  698.  
  699.     if (strcmp (tampon,"")) {
  700.         strcat (commande," -b");
  701.         strcat (commande,tampon);
  702.         }
  703.  
  704.     if (strcmp (qualite,"")) {
  705.         strcat (commande," -q");
  706.         strcat (commande,qualite);
  707.         }
  708.  
  709.     if ((Gadget8.Flags & SELECTED)==SELECTED)
  710.         strcat (commande," +d");
  711.     else strcat (commande," -d");
  712.  
  713.     if ((Gadget9.Flags & SELECTED)==SELECTED)
  714.         strcat (commande," +p");
  715.     else strcat (commande," -p");
  716.  
  717.     if ((Gadget14.Flags & SELECTED)==SELECTED) {
  718.         strcat (commande," +f -o");
  719.         strcat (commande,cible);
  720.         }
  721.     else strcat (commande," -f");
  722.  
  723.     if ((Gadget10.Flags & SELECTED)==SELECTED)
  724.         strcat (commande," +v");
  725.     else strcat (commande," -v");
  726.  
  727.     strcat (commande," >con:0/0/640/200/DKB-Trace");
  728.  
  729.     Execute (commande,NULL,Output());
  730. }
  731.  
  732. void ferme()
  733. {
  734.     if (f1) CloseWindow(f1);
  735.     if (ReqBase) CloseLibrary(ReqBase);
  736. }
  737.  
  738. void charge_config()
  739. {
  740. FILE *config=NULL;
  741.  
  742.     if ((config=fopen(fichier_config,"rt"))==NULL)
  743.     {
  744.         SimpleRequest ("impossible de charger le fichier de configuration");
  745.         exit(15);
  746.     }
  747.     fscanf (config,"%s %s %s",nom_calcul,source_dir,cible_dir);
  748.     fclose (config);
  749. }
  750.  
  751. void ouvre()
  752. {
  753.     if ((ReqBase = (struct ReqBase *)OpenLibrary ("req.library",REQVERSION))==0)
  754.     {
  755.         fprintf (stderr,"impossible d'ouvrir la librairie REQ\n");
  756.         exit(15);
  757.     }
  758.     f1 = (struct Window *)OpenWindow (&NewWindowStructure1);
  759.  
  760. }
  761.  
  762. void wbmain()
  763. {
  764.     int nb;
  765.     atexit (ferme);
  766.  
  767.     ouvre();
  768.     charge_config();
  769.     do
  770.     {
  771.         Delay (5);
  772.         while (im=(struct IntuiMessage *) GetMsg(f1->UserPort))
  773.         switch (im->Class)
  774.         {
  775.         case CLOSEWINDOW :
  776.             ReplyMsg(im);
  777.             exit(0);
  778.         case GADGETUP :
  779.             nb=((struct Gadget *)im->IAddress)->GadgetID;
  780.         if (nb==13) feu();
  781.         if (nb==12) fichier_cible();
  782.         if (nb==11) fichier_source();
  783.         if (nb==1) saisie_hauteur();
  784.         if (nb==2) saisie_largeur();
  785.         if (nb==3) saisie_debut();
  786.         if (nb==4) saisie_fin();
  787.         if (nb==5) saisie_lissage();
  788.         if (nb==6) saisie_qualite();
  789.         if (nb==7) saisie_tampon();
  790.         if (drapeau==1)
  791.         {
  792.             ReplyMsg(im);
  793.             exit(0);
  794.         }
  795.         }
  796.     }
  797.     while (TRUE);
  798. }
  799.  
  800. void main()
  801. {
  802.     wbmain();
  803. }
  804.